//import Vue from 'vue'
//import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'

//Vue.use(Router)
//默认cdn引入的全局变量是VueRouter
const router = new VueRouter({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld,
      meta: {
        title: "哇咔咔",
        keepAlive: true,
        background: "#F4F4F4"
      }
    }
  ]
});
/**
 * 注册一个全局前置守卫
 */
router.beforeEach((to, from, next) => {
  //设置页面title、
  if (to.meta.title !== undefined) window.document.title = to.meta.title;
  //页面背景颜色
  if (to.meta.background !== undefined) {
    document.body.style.backgroundColor = to.meta.background;
  } else {
    document.body.style.backgroundColor = "#FFF";
  }
  next();
});

export default router;